package com.ce.pms.charge.web;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletResponse;

import com.ce.pms.base.web.PmsBaseAction;
import com.ce.pms.charge.model.AbstractSubAccount;
import com.ce.pms.charge.model.AccountDomain;
import com.ce.pms.charge.model.ChargeAccountDomain;
import com.ce.pms.charge.model.ParameterDefDomain;
import com.ce.pms.charge.model.PeriodDomain;
import com.ce.pms.charge.service.IAccountService;
import com.ce.pms.charge.service.IBankAccountService;
import com.ce.pms.charge.service.IBankCollectionService;
import com.ce.pms.charge.service.IBusinessCodeService;
import com.ce.pms.charge.service.ICashieringService;
import com.ce.pms.charge.service.ICharStoChoGeneralService;
import com.ce.pms.charge.service.IChargeItemService;
import com.ce.pms.charge.service.IChargeStaService;
import com.ce.pms.charge.service.IFeeBankService;
import com.ce.pms.charge.service.IMeterDataRegisterService;
import com.ce.pms.charge.service.INonConventionalChargeService;
import com.ce.pms.charge.service.INoteService;
import com.ce.pms.charge.service.IParameterDefService;
import com.ce.pms.charge.service.IPeriodService;
import com.ce.pms.charge.service.IPrePaySchService;
import com.ce.pms.charge.service.ISubAccountService;
import com.ce.pms.charge.service.ITransactionService;
import com.ce.pms.charge.vo.AdjustTransactionVO;
import com.ce.pms.charge.vo.BankAccountVO;
import com.ce.pms.charge.vo.BusinessCodeVO;
import com.ce.pms.charge.vo.CashieringSearchVO;
import com.ce.pms.charge.vo.ChargeDetailSearchVO;
import com.ce.pms.charge.vo.ChargeItemVO;
import com.ce.pms.charge.vo.ChargeRecordVO;
import com.ce.pms.charge.vo.ChargeStaChoVO;
import com.ce.pms.charge.vo.ChargeStaVO;
import com.ce.pms.charge.vo.ChargeStaVersionVO;
import com.ce.pms.charge.vo.CheckBox;
import com.ce.pms.charge.vo.CreditTransVO;
import com.ce.pms.charge.vo.DebitTransVO;
import com.ce.pms.charge.vo.DepositTransSearchVO;
import com.ce.pms.charge.vo.DepositTransVO;
import com.ce.pms.charge.vo.HistoryAccountVO;
import com.ce.pms.charge.vo.HouseChargeVO;
import com.ce.pms.charge.vo.LateFeeDetailVO;
import com.ce.pms.charge.vo.NoteVO;
import com.ce.pms.charge.vo.OriginalMeterDataVO;
import com.ce.pms.charge.vo.ParameterDefVO;
import com.ce.pms.charge.vo.PeriodVO;
import com.ce.pms.charge.vo.PrePayAccountVO;
import com.ce.pms.charge.vo.PrePaySchChargeVO;
import com.ce.pms.charge.vo.TransactionVO;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.common.util.BigDecimalUtil;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.house.model.MeterType;
import com.ce.pms.house.service.ICoalitionHouseService;
import com.ce.pms.house.service.IHouseService;
import com.ce.pms.house.service.IMeterService;
import com.ce.pms.house.vo.CoalitionHouseVO;
import com.ce.pms.house.vo.HouseVO;
import com.ce.util.BlankUtil;
import com.ce.util.XMLAbout;
import com.sitechasia.webx.components.xtable.util.ExtremeUtils;
import com.sitechasia.webx.core.annotation.Out;
import com.sitechasia.webx.core.annotation.Read;
import com.sitechasia.webx.core.support.Page;

/**
 * 功能描述:
 * <p>版权所有：中企动力
 * <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
 *
 * @author  许海堆
 * Created on  2008-8-12
 * @author
 * update on
 */

public class CashieringAction extends PmsBaseAction{



	public String initCashieringMain(){
		return "initCashieringMain";
	}

	/**
	 * 功能描述:根据输入的房间号码进行查询
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-29
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
	public String getResearchList(@Read(key="houseNumber",defaultValue="")String houseNumber,
			@Read(key = "ec_crd",defaultValue="15")	int pageSize,
            @Read(key = "ec_p", defaultValue="1")	int pageNo){

		//保存到ruquest中去，在分页中应用
		this.getRequest().setAttribute("houseNumber", houseNumber);

		//设置查询条件
		CashieringSearchVO searchVO = new CashieringSearchVO();
		searchVO.setHouseNumber(houseNumber);
		searchVO.setPageSize(pageSize);
		searchVO.setPageNo(pageNo);
		Page page=new Page();

		if(!(BlankUtil.isBlank(houseNumber))){
             //获得当前有效的房间列表
			page = cashieringService.getEffectiveHouseChargeInfo(searchVO);

			//当前有效房间列表没有记录时，，才查询历史中房间的列表
			if(page.getResult().size()<1){
				page=cashieringService.getLastHouseChargeInfo(searchVO);
			}
		}

		this.getRequest().setAttribute("cashierList", page.getResult());
		this.getRequest().setAttribute("totalRows", new Integer(page.getResult().size()));

        return "rightHouseList";

	}

	/**
	 * 功能描述:获得房间的详细（包括银行帐户信息，欠费信息，余额信息）
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-29
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
	public String getHouseChargeMessage(@Read(key="keyword")Long keyword,
			@Read(key="link")@Out(key="link") boolean link,
			@Read(key="proRightId")Long proRightId,
			@Read(key="accountId")Long accountId,
			@Read(key="chargeSelect")String chargeSelect){

		CashieringSearchVO searchVo = new CashieringSearchVO();
		searchVo.setHouseId(keyword);
		searchVo.setProRightId(proRightId);
		searchVo.setAccountId(accountId);
		HistoryAccountVO vo=cashieringService.queryHouseChargeDetailInfo(searchVo);
        if(BlankUtil.isBlank(chargeSelect)){
        	chargeSelect=vo.getChargeSelect();
        }
		String forward="";

		//如果房间是产权房或者管理房（帐户是合并记账）
		if(BlankUtil.isBlank(vo.getRelHouses())){

			forward="cashieringHouseMessage";

			//如果房间是在某个管理房，但又是分开记账的
		} else {
			forward="cashieringHouseRelationMessage";
		}
		//isHistory  是否是历史帐户信息 1是  0否
		//isChangeProRight 房间是否已经发生过产权变更记录： 1是  0否
		//showButtomType 1只有历史帐户历史按钮  0 只有银行帐户管理按钮  2两个按钮都有
		if(!BlankUtil.isBlank(vo.getIsChangeProRight()) && HouseChargeVO.IS_CHANGE_PRO_RIGHT_1.equals(vo.getIsChangeProRight())){

			this.getRequest().setAttribute("showButtomType", "1");

		}

		if(!BlankUtil.isBlank(vo.getIsHistory()) && HouseChargeVO.IS_HISTORY_0.equals(vo.getIsHistory())){
			//如果是分开记账并且是产权房
			if("1".equalsIgnoreCase(chargeSelect)&& "0".equalsIgnoreCase(vo.getIsVirtual())){
			this.getRequest().setAttribute("showButtomType", "0");
			}
			//如果是合并记账，并且是管理房
			if("0".equalsIgnoreCase(chargeSelect)&& "1".equalsIgnoreCase(vo.getIsVirtual())){
				this.getRequest().setAttribute("showButtomType", "0");
			}
		}

		if(!BlankUtil.isBlank(vo.getIsChangeProRight()) && !BlankUtil.isBlank(vo.getIsHistory())) {
			if( HouseChargeVO.IS_CHANGE_PRO_RIGHT_1.equals(vo.getIsChangeProRight()) && HouseChargeVO.IS_HISTORY_0.equals(vo.getIsHistory())){
				if("1".equalsIgnoreCase(chargeSelect)&& "0".equalsIgnoreCase(vo.getIsVirtual())){
					this.getRequest().setAttribute("showButtomType", "2");
				}else if("0".equalsIgnoreCase(chargeSelect)&& "1".equalsIgnoreCase(vo.getIsVirtual())){
					this.getRequest().setAttribute("showButtomType", "2");
				}else {
					this.getRequest().setAttribute("showButtomType", "1");
				}

			}
		}

		this.getRequest().setAttribute("view", vo);

		return forward;
	}

	/**
	 * 功能描述:初始化房间历史帐户列表
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-20
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
	public String initHistoryAccount(@Read(key="keyword")Long keyword,
			@Read(key = "ec_crd",defaultValue="2")	int pageSize,
            @Read(key = "ec_p", defaultValue="1")	int pageNo){

		CashieringSearchVO searchVo = new CashieringSearchVO();
		searchVo.setHouseId(keyword);
		searchVo.setPageSize(pageSize);
		searchVo.setPageNo(pageNo);
		Page page=cashieringService.queryHouseChargeHistoryListByPage(searchVo);
		this.getRequest().setAttribute("historyAcounetList", page.getResult());
		this.getRequest().setAttribute("totalRows", Long.valueOf(page.getTotalCount()).intValue());
		this.getRequest().setAttribute("keyword", keyword);
		return "historyAccount";
	}

	/**
	 * 功能描述:初始化房间主线界面历史帐户列表<br>
	 * @param <br>
	 * @return<br>
	 *
	 * Create author:xuhaidui<br>
	 * Create on:2009-1-22<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public String houseMainLineHistoryAccountList(@Read(key="keyword")Long keyword,
			@Read(key = "ec_crd",defaultValue="2")	int pageSize,
            @Read(key = "ec_p", defaultValue="1")	int pageNo){
		initHistoryAccount(keyword,pageSize,pageNo);
		return "houseMainLineHistoryAccountList";
	}




	/**
	 * 功能描述:初始化增加房间的银行帐户
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-20
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
	public String initAddBankAccount(@Read(key="keyword")@Out(key="keyword")Long keyword,
			@Read(key="proRightId")@Out(key="proRightId")Long proRightId){
		setAttribute("bankList", feeBankService.getAllBankList());//获取所有银行名称
		return "addHouseBankAccount";
	}

	/**
	 * 功能描述:保存房间的银行帐户
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-29
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
	public String addBankAccount(@Read BankAccountVO vo){
		vo.setCreator(this.getUserId());
		bankAccountService.addBankAccount(vo);
		this.getRequest().setAttribute("refreshIframe", "cashieringList");
		return "onlyRefresh";
	}


	/**
	 * 功能描述:初始化修改房间的银行帐户
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-20
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String initEditBankAccount(@Read(key="keyword")@Out(key="keyword")Long keyword,
			@Read(key="proRightId")@Out(key="proRightId")Long proRightId){
    	BankAccountVO vo = bankAccountService.getCurrentBankAccount(keyword);
    	this.getRequest().setAttribute("view", vo);
    	setAttribute("bankList", feeBankService.getAllBankList());//获取所有银行名称
    	return "editHouseBankAccount";
	}

    /**
	 * 功能描述:更换房间的银行帐户
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String editBankAccount(@Read BankAccountVO vo,
    		@Read(key="oldAccNumber")String oldAccNumber){
    	vo.setCreator(this.getUserId());
		// 如果出盘锁定，不能修改，否则禁用原账号，再新增一个账号
    	if(BlankUtil.isBlank(oldAccNumber) ||collectionService.isIn(oldAccNumber)){

    	//从未出过盘，直接修改
    	   bankAccountService.editBankAccount(vo);
    	}else{
    		//该银行帐户还存在没有回盘的记录，不能修改
    		throw new BusinessException("charge:charge_bankaccount_not_in_edit",BusinessException.WARNING);
    	}

    	this.getRequest().setAttribute("refreshIframe", "cashieringList");
    	return "onlyRefresh";
    }

    /**
	 * 功能描述:删除房间的银行帐户
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String deleteBankAccount(@Read(key="bankAccountId")Long bankAccountId,
    		@Read(key="accNumber")String accNumber){

    	// 如果出盘锁定，不能禁用账号，否则直接禁用
    	if(collectionService.isIn(accNumber)){
    	bankAccountService.disableBankAccount(bankAccountId, this.getUserId());
    	}else{
    		//该银行帐户还存在没有回盘的记录，不能删除
    		throw new BusinessException("charge:charge_bankaccount_not_in_delete",BusinessException.WARNING);
    	}
    	this.getRequest().setAttribute("refreshIframe", "cashieringList");
    	return "onlyRefresh";
    }

    /**
	 * 功能描述:初始化前台收费tab页的预交款主页面
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String cashieringPrepayList(@Read(key="keyword")@Out(key="keyword")Long keyword,
    		                          @Read(key="isShowButtom")@Out(key="isShowButtom")boolean isShowButtom,
    		                          @Read(key="proRightId")@Out(key="proRightId")Long proRightId,
    		                          @Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
    		                  		@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
    		                  		@Read(key="accountId")@Out(key="accountId")Long accountId){


    	return "cashieringPrepayList";
    }



    /**
	 * 功能描述:初始化收费页面
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String initGathering(@Read(key="keyword")@Out(key="keyword")Long keyword,
    		@Read(key="proRightId")@Out(key="proRightId")Long proRightId,
    		@Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
    		@Read(key="isVirtual")@Out(key="isVirtual") String isVirtual,
    		@Read(key="accountId")@Out(key="accountId")Long accountId){

    	PrePayAccountVO vo= subAccountService.getPrePayAccountById(accountId);
    	//判断房间是否已经有预交款方案
    	if(!subAccountService.checkIsChoosePerPaySch(vo.getSubAccountId())){
         //如果没有，则给出提示
    		throw new BusinessException("charge:prepayNoScheme",BusinessException.WARNING);
    	}
    	this.getRequest().setAttribute("schemeName", vo.getSchemeName());


    	setAttribute("accountHouseId", keyword);//房间id就是记账帐户id
    	//缴费方式
    	List<BusinessCodeVO> blistTemp = businessCodeService.getAllCreditBusinessCodeList();
    	List<BusinessCodeVO> blist =new ArrayList();
//    	MULTIPLE_PAY_CODE  PRE_PAY_CODE BANK_PAID_CODE
    	List<ParameterDefDomain> parameterList=parameterDefService.getNotInCode("'MULTIPLE_PAY_CODE','PRE_PAY_CODE','BANK_PAID_CODE'");
    	Map map=new HashMap();
    	for(ParameterDefDomain tempDO:parameterList){
    		if(BlankUtil.isBlank(tempDO.getPvalue())){
    			continue;
    		}
    		map.put(tempDO.getPvalue().toString(), tempDO.getPvalue().toString());
    	}
    	for(BusinessCodeVO businessCodeVO:blistTemp){
    		if(map.containsKey(businessCodeVO.getKeyword().toString()))continue;
    		businessCodeVO.setDescription(businessCodeVO.getBizCode()+"-"+businessCodeVO.getDescription());

    		blist.add(businessCodeVO);
    	}
    	setAttribute("businessCodeList", blist);

    	this.getRequest().setAttribute("defaultDate", new Date());

    	return "gathering";
    }

    /**
	 * 功能描述:保存前台收款
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String gathering(@Read PrePaySchChargeVO prePaySchChargeVO,
    		@Read(key="saveAgain")@Out(key="saveAgain")boolean saveAgain,
    		@Read(key="keyword")@Out(key="keyword")Long keyword,
    		@Read(key="proRightId")@Out(key="proRightId")Long proRightId,
    		@Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
    		@Read(key="isVirtual")@Out(key="isVirtual") String isVirtual){
    	this.getRequest().setAttribute("accountId", prePaySchChargeVO.getAccountId());
    	this.getRequest().setAttribute("refreshIframe", "connTabPanel");
    	prePaySchChargeVO.setCreator(getUserId());
    	//设置管理区编号
    	prePaySchChargeVO.setPrecinctCode(getPrecinctVOByHouseId(keyword,isVirtual));
    	//设置当前楼栋的收费周期
    	prePaySchChargeVO.setPeriodId(periodService.queryCurrentPeriod().getKeyword());
    	cashieringService.receivedPrePaySchCharge(prePaySchChargeVO);
    	if(saveAgain){
    		return initGathering(keyword,proRightId,chargeSelect,isVirtual,prePaySchChargeVO.getAccountId());
    	}else {

    	    return "onlyRefresh";
    	}
    }

    /**
	 * 功能描述:初始化前台收费tab页的押金/保证金主页面
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String cashieringDepositMain(@Read(key="keyword")@Out(key="keyword")Long keyword,
    		                          @Read(key="isShowButtom")@Out(key="isShowButtom")boolean isShowButtom,
    		                          @Read(key="proRightId")@Out(key="proRightId")Long proRightId,
    		                          @Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
    		                  		@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
    		                  		@Read(key="accountId")@Out(key="accountId")Long accountId){


    	return "cashieringDepositMain";
    }


    public String cashieringDepositList(@Read(key="accountId")@Out(key="accountId")Long accountId,
    		@Read(key = "ec_crd",defaultValue="10")	Integer pageSize,
            @Read(key = "ec_p", defaultValue="1")	Integer pageNo){
    	DepositTransSearchVO depositTransSearchVO = new DepositTransSearchVO();
    	depositTransSearchVO.setAccountId(accountId);
    	depositTransSearchVO.setPageNo(pageNo);
    	depositTransSearchVO.setPageSize(pageSize);
    	depositTransSearchVO.setSortStr(ExtremeUtils.getOrderString(this.getRequest()));
    	Page page=transactionService.queryDepositTransVOByPage(depositTransSearchVO);
    	this.getRequest().setAttribute("list", page.getResult());
		this.getRequest().setAttribute("totalRows", Long.valueOf(page.getTotalCount()).intValue());

		BigDecimal depositCount=accountService.getDepositAccountBalance(accountId);
    	this.getRequest().setAttribute("depositCount", depositCount);
    	return "cashieringDepositList";
    }

    /**
	 * 功能描述:初始化押金/保证金收费页面
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String initGatheringDeposit(@Read(key="keyword")@Out(key="keyword")Long keyword){

    	//缴费方式
    	List<BusinessCodeVO> blistTemp = businessCodeService.getAllCreditBusinessCodeList();

    	List<BusinessCodeVO> blist =new ArrayList();
//    	MULTIPLE_PAY_CODE  PRE_PAY_CODE BANK_PAID_CODE
    	List<ParameterDefDomain> parameterList=parameterDefService.getNotInCode("'MULTIPLE_PAY_CODE','PRE_PAY_CODE','BANK_PAID_CODE'");
    	Map map=new HashMap();
    	for(ParameterDefDomain tempDO:parameterList){
    		if(BlankUtil.isBlank(tempDO.getPvalue())){
    			continue;
    		}
    		map.put(tempDO.getPvalue().toString(), tempDO.getPvalue().toString());
    	}
    	for(BusinessCodeVO businessCodeVO:blistTemp){
    		if(map.containsKey(businessCodeVO.getKeyword().toString()))continue;
    		businessCodeVO.setDescription(businessCodeVO.getBizCode()+"-"+businessCodeVO.getDescription());

    		blist.add(businessCodeVO);
    	}
    	setAttribute("businessCodeList", blist);

    	return "gatheringDeposit";
    }

    /**
	 * 功能描述:保存押金/保证金收费页面
	 * @param
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-8-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String gatheringDeposit(@Read DepositTransVO depositTransVO,
    		@Read(key="saveAgain")@Out(key="saveAgain")boolean saveAgain,
    		@Read(key="keyword")@Out(key="keyword")Long keyword){

    	this.getRequest().setAttribute("refreshIframe", "connTabPanel");

    	depositTransVO.setCreator(this.getUserId());

    	transactionService.addDepositCharge(depositTransVO);
    	if(saveAgain){
    		return initGatheringDeposit(keyword);
    	}else {

    	    return "onlyRefresh";
    	}
    }



	/***
	 * 功能描述:  跳转前台收费费用明细主页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-28  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initChargeDetailMain(
			@Read(key="houseId")@Out(key="houseId")Long keyword,
			@Read(key="isShowButtom")@Out(key="isShowButtom")boolean isShowButtom,
			@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
			@Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
			@Read(key="accountId")@Out(key="accountId") Long accountId,
			@Read(key="proRightId")@Out(key="proRightId") Long proRightId)
	{
		setAttribute("periodList", getAllPeriod());
		PeriodVO period= periodService.queryCurrentPeriod();
		setAttribute("periodId", period.getKeyword());
		setAttribute("periodStr", period.getPeriod());

		//用于重算
		StringBuffer houseIds = new StringBuffer();
		StringBuffer houseNumbers = new StringBuffer();
		if(SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(virtual))
		{
			List<HouseVO> list =  coalitionHouseService.getPropertyHouseByCoalitionId(keyword);
			for(HouseVO house : list)
			{
				houseIds.append(house.getKeyword()).append(",");
				houseNumbers.append(house.getHouseNumber()).append(",");
			}
			houseIds = houseIds.deleteCharAt(houseIds.length()-1);
			houseNumbers = houseNumbers.deleteCharAt(houseNumbers.length()-1);

		}else{
			houseIds.append(keyword);
			HouseVO house = houseService.getFlatHouseById(keyword);
			houseNumbers.append(house.getHouseNumber());
		}
		setAttribute("houseIds", houseIds);
		setAttribute("houseNumbers", houseNumbers);

		setAttribute("status",sysrefcodeService.getSysrefCodesByCode(SysrefcodeDO.FEE_TRANSACTION_STATUZ, SysrefcodeDO.FEE_TRANSACTION_STATUZ_NOTPAY).getId());
		return "initChargeDetailMain";
	}



	/***
	 * 功能描述: 跳转前台收费费用明细列表页面 <br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-28  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initChargeDetailList(
			@Read(key="periodId")@Out(key="periodId")Long periodId,
			@Read(key="accountId")@Out(key="accountId")Long accountId,
			@Read(key="periodStr")@Out(key="periodStr")String periodStr,
			@Read(key="accountHouseId")@Out(key="accountHouseId")Long accountHouseId,
			@Read(key="flag")Long flag,
			@Read(key="stat")@Out(key="stat")Long statusId)
	{
		ChargeDetailSearchVO searchVo = new ChargeDetailSearchVO();
		searchVo.setAccountId(accountId);
		PeriodVO period= periodService.queryCurrentPeriod();
		if(BlankUtil.isBlank(period) || !period.getKeyword().equals(periodId)){
			searchVo.setPreviousPeriod(true);
		}
		searchVo.setPeriod(periodStr);
		searchVo.setPeriodId(periodId);

		if(!BlankUtil.isBlank(statusId)){
			SysrefcodeDO sysref =  sysrefcodeService.findSysrefcodeById(statusId);
			searchVo.setStatuz(sysref.getValue());
			searchVo.setOnlyDebit(true);
		}
		List<TransactionVO> temp = transactionService.getTransactionVoByConditions(searchVo);
		List list = initChargeDetailList(temp.subList(0, temp.size()-1));
		//账户余额
		if(flag != null && SysrefcodeDO.CONSTANTS_ONE == flag.intValue())
		{
			BigDecimal leftTotal = accountService.getChargeAccountBalance(accountId);
			setAttribute("leftTotal", leftTotal);
			BigDecimal lateFeeTatal=cashieringService.queryLatefeeByAccountId(accountId);
			setAttribute("lateFeeTotal", lateFeeTatal);
		}
		setAttribute("chargeDetailList", list);
		setAttribute("accountHouseId",accountHouseId);
		//费用明细总计
		setAttribute("totalCurrency", temp.get(temp.size()-1));

		setAttribute("totalRows", new Integer(list.size()));
		return "initChargeDetailList";
	}


	/***
	 * 功能描述: 查看交易详细信息(只对支付类型的有效) <br>
	 * @param id 交易ID
	 * @param clazz 交易类型
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-1  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String showDetail(@Read(key="tractionId") Long id)
	{
		return getMultiPayDetailBy(id);
	}



	/***
	 * 功能描述:  根据支付交易ID获取交易明细<br>
	 * @param id
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-28  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getMultiPayDetailBy(@Read(key="tractionId")Long id)
	{
		CreditTransVO credit = transactionService.getCreditTransVOById(id, true);
		List<TransactionVO> payModeList = credit.getChildrenList();
		List<TransactionVO> debitList = credit.getDebitsList();
		setAttribute("payModeList", payModeList);//支付方式
		setAttribute("size",payModeList.size());
		setAttribute("multiPayDetailList",debitList);//支付明细
		setAttribute("totalRows",new Integer(debitList.size()));
		return "multiPayDetail";
	}


	/***
     * 功能描述: 滞纳金明细 <br>
     * @param id
     * @return
     * Create author:yandawei <br>
     * Create on:2008-9-1  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
	public String getLateFeeDetail(@Read(key="tractionId") Long id)
	{
		List<LateFeeDetailVO> list = transactionService.getLateFeeDetailListById( id);
		setAttribute("lateFeeList", list.subList(0, list.size()-1));
		setAttribute("totalRows",new Integer(list.size()));
		setAttribute("totalCurrency", list.get(list.size()-1).getLatefee());
		return "lateFeeDetail";
	}


    /***
     * 功能描述:  前台收费数据录入查询主界面<br>
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String initDataRegisterMain(
    		@Read(key="keyword")@Out(key="houseId")Long houseId,
    		@Read(key="proRightId")@Out(key="proRightId") Long proRightId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual)
    {
		List<MeterType> meterTypeList = meterService.getMeterTypeList();
		setAttribute("meterTypeList", meterTypeList);
		setAttribute("periodList",  getAllPeriod());
    	return "initDataRegisterMain";
    }


    /***
     * 功能描述:  初始化前台收费数据录入列表页面<br>
     * @param
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String initDataRegisterList(
    		@Read(key="houseId")@Out(key="houseId")Long houseId,
    		@Read(key="proRightId")@Out(key="proRightId") Long proRightId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual)
    {
    	setAttribute("totalRows",new Integer(0));
    	return "initDataRegisterList";
    }


    /***
     * 功能描述:  前台收费数据录入列表页面<br>
     * @param OriginalMeterDataVO
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String requestDataRegisterList(
    		@Read OriginalMeterDataVO queryDataVO,
    		@Read(key="houseId")@Out(key="houseId")Long houseId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
    		@Read(key = "ec_crd",defaultValue="10")	int pageSize,
            @Read(key = "ec_p", defaultValue="1")	int pageNo)
    {
    	if(SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(virtual)){
			List<HouseVO> list =  coalitionHouseService.getPropertyHouseByCoalitionId(houseId);
			StringBuffer houseIds = new StringBuffer();
			for(HouseVO house: list){
				houseIds.append(house.getKeyword()).append(",");
			}
			houseIds = houseIds.deleteCharAt(houseIds.length()-1);
			queryDataVO.setHouseIds(houseIds.toString());
			queryDataVO.setHouseId(null);
		}

    	Page page = meterDataRegisterService.getChargeDatasVOsByPage(queryDataVO, pageNo, pageSize);
    	if(!BlankUtil.isBlank(page)){
			setAttribute("dataRegisterList", page.getResult());
			setAttribute("totalRows",Integer.valueOf(String.valueOf(page.getTotalCount())));
		}else{
			setAttribute("dataRegisterList", null);
			setAttribute("totalRows",new Integer(0));
		}
    	//保存查询条件
    	setAttribute("queryDataVO", queryDataVO);
    	return "initDataRegisterList";
    }

    /***
     * 功能描述: 前台收费通知单查询主界面 <br>
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String initRequisitionMain(
    		@Read(key="keyword")@Out(key="houseId")Long houseId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
    		@Read(key="proRightId")@Out(key="proRightId") Long proRightId,
    		@Read(key="isShowButtom")@Out(key="isShowButtom")boolean isShowButtom){
    	setAttribute("periodList", getAllPeriod());
    	return "initRequisitionMain";
    }

    /***
     * 功能描述: 初始化前台收费通知单列表界面 <br>
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String initRequistionList(
    		@Read(key="houseId")@Out(key="houseId")Long houseId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual)
    {
    	setAttribute("totalRows",new Integer(0));
    	return "initRequistionList";
    }

    /***
     * 功能描述: 前台收费通知单列表界面 <br>
     * @return
     * Create author:yandawei <br>
     * Create on:2008-8-28  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
    public String requestRequistionList(
    		@Read NoteVO queryVO,
    		@Read(key="houseId")@Out(key="houseId")Long houseId,
    		@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
    		@Read(key="proRightId")@Out(key="proRightId") Long proRightId,
    		@Read(key = "ec_crd",defaultValue="10")	int pageSize,
            @Read(key = "ec_p", defaultValue="1")	int pageNo){
    	queryVO.setPageNo(pageNo);
		queryVO.setPageSize(pageSize);
		queryVO.setProRightIds(String.valueOf(proRightId));
		queryVO.setHouseId(houseId);
		//是否为管理房(当前业务管理房就只查管理房的通知单)
//		if(SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(virtual))
//		{
//			List<HouseVO> list =  coalitionHouseService.getPropertyHouseByCoalitionId(houseId);
//			StringBuffer houseIds = new StringBuffer(String.valueOf(houseId)).append(",");
//			for(HouseVO house: list){
//				houseIds.append(house.getKeyword()).append(",");
//			}
//			houseIds = houseIds.deleteCharAt(houseIds.length()-1);
//			queryVO.setHouseIds(houseIds.toString());
//			queryVO.setHouseId(null);
//		}
    	Page page = noteService.queryNote(queryVO);
    	if(!BlankUtil.isBlank(page)){
			setAttribute("noteList", page.getResult());
			setAttribute("totalRows",Integer.valueOf(String.valueOf(page.getTotalCount())));
		}else{
			setAttribute("totalRows",Integer.valueOf(0));
		}
    	//保存查询条件
    	setAttribute("queryVO", queryVO);
    	return "initRequistionList";
    }



	/***
	 * 功能描述:  入账初始化页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-1  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRecordedAccountAdd(
			@Read(key="houseId")@Out(key="houseId")Long houseId,
			@Read(key="isVirtual")@Out(key="isVirtual") String virtual,
			@Read(key="chargeSelect")@Out(key="chargeSelect") String chargeSelect,
			@Read(key="accountId") Long accountId,
			@Read(key="proRightId") Long proRightId)
	{
		AccountDomain account = accountService.getAccountDoById(accountId);
		Set<AbstractSubAccount> subAccountSet = account.getSubAccounts();
		for(AbstractSubAccount subAccount : subAccountSet){
			if(subAccount instanceof ChargeAccountDomain){
				ChargeAccountDomain sub = (ChargeAccountDomain) subAccount;
				checkChargeAccountDebitStatus(sub);
				break;
			}
		}
		CashieringSearchVO searchVo = new CashieringSearchVO();
		searchVo.setHouseId(houseId);
		searchVo.setProRightId(proRightId);
		searchVo.setAccountId(accountId);
		HistoryAccountVO vo=cashieringService.queryHouseChargeDetailInfo(searchVo);
		setAttribute("houseNumber",vo.getHouseNumber());
		setAttribute("participantName",vo.getParticipantName());
		setAttribute("chargeItemList", getAllHouseSelectChargeItem(houseId));
		setAttribute("accountHouseId", houseId);
		if(SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(virtual))
		{
			CoalitionHouseVO house = coalitionHouseService.findCoalitionHouseById(houseId);
			List<HouseVO> list =  coalitionHouseService.getPropertyHouseByCoalitionId(houseId);
			setAttribute("coalitionHouseNumber", house.getCoalitionHouseNumber());
			setAttribute("houseList", list);
		}
		else
		{
			PeriodDomain period =  periodService.findPeriodByHouseId(houseId);
			setAttribute("periodId",period.getKeyword());
		}

		return "recordedAccountAdd";
	}



	/***
	 * 功能描述:  判断物业帐户借状态是否锁定<br>
	 * @param chargeAccount
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-10-22  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void checkChargeAccountDebitStatus(ChargeAccountDomain chargeAccount){
		boolean result =  subAccountService.isLockDebit(chargeAccount.getSubAccountId());
		if(result){
			throw new BusinessException("charge:charge_account_debit_locked",BusinessException.WARNING);
		}
	}

	/***
	 * 功能描述:  添加一条入账记录<br>
	 * @param debitTransVO
	 * Create author:yandawei <br>
	 * Create on:2008-9-1  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addRecordedAccount(@Read DebitTransVO debitTransVO)
	{
		debitTransVO.setCreator(getUserId());
		ChargeItemVO chargeItem =  chargeItemService.findChargeItemById(debitTransVO.getChargeItemId());
		debitTransVO.setBusinessId(chargeItem.getBusinessCodeId());
		cashieringService.inputAccountForHand(debitTransVO);
		renderText("true");
	}


	/***
	 * 功能描述:  初始化缴费页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initPayBillsAdd(
			@Read(key="accountId")@Out(key="accountId")Long accountId,
			@Read(key="accountHouseId")@Out(key="accountHouseId") Long accountHouseId,
			@Read(key="isVirtual")@Out(key="isVirtual") String virtual)
	{
		List<BusinessCodeVO> list = businessCodeService.getAllCreditBusinessCodeList();
		if(BlankUtil.isBlank(list)){
			throw new BusinessException("charge:charge_paybusinesscode_not_exist",BusinessException.WARNING);
		}
		StringBuffer payModeStr = new StringBuffer();
		for(BusinessCodeVO business : list)
		{
			payModeStr.append(business.getKeyword())
					  .append(",")
					  .append(business.getBizCode()).append("-").append(business.getDescription()).append(";");
		}
		//支付方式
		setAttribute("payModeStr", payModeStr.toString());
		return "payBillsAdd";
	}

	/***
	 * 功能描述:  初始化缴费主页面<br>
	 * @return
	 * Create author:xuhaidui <br>
	 * Create on:2008-12-22  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initPayBillsMain(@Read(key="accountId")@Out(key="accountId")Long accountId,
			@Read(key="accountHouseId")@Out(key="accountHouseId") Long accountHouseId,
			@Read(key="isVirtual")@Out(key="isVirtual") String virtual){
		return "payBillsMain";

	}

	/**
	 * 功能描述:初始化收费中tab的其它业务收费<br>
	 * @param <br>
	 * @return<br>
	 *
	 * Create author:xuhaidui<br>
	 * Create on:2008-12-22<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public String initOtherPayBills(@Read(key="accountId")@Out(key="accountId")Long accountId,
			@Read(key="accountHouseId")@Out(key="accountHouseId") Long accountHouseId,
			@Read(key="isVirtual")@Out(key="isVirtual") String virtual){
		List<BusinessCodeVO> list = businessCodeService.getAllCreditBusinessCodeList();
		List<BusinessCodeVO> blist =new ArrayList();
		for(BusinessCodeVO businessCodeVO:list){

    		businessCodeVO.setDescription(businessCodeVO.getBizCode()+"-"+businessCodeVO.getDescription());

    		blist.add(businessCodeVO);
    	}
		this.getRequest().setAttribute("payModeList", blist);
		this.getRequest().setAttribute("creatDate", new Date());
		return "otherPayBills";
	}

	/**
	 * 功能描述:其它业务收费列表<br>
	 * @param <br>
	 * @return<br>
	 *
	 * Create author:xuhaidui<br>
	 * Create on:2008-12-22<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public String otherPayBillList(@Read(key="accountHouseId") Long accountHouseId){
		this.getRequest().getSession().setAttribute(SELECT_OTHER_CHARGE_LIST, null);
		List<ChargeRecordVO> chargeItemList=nonConventionalChargeService.getUnHandleChargeRecords(accountHouseId);

		Page page = new Page();

		page.setResult(chargeItemList);
		Map map = new HashMap<String, ChargeRecordVO>();
		for(ChargeRecordVO vo:chargeItemList){
			map.put(vo.getKeyword().toString(), vo);
		}
		setAttribute("otherPayBillList", chargeItemList);

		this.getRequest().getSession().setAttribute(SELECT_OTHER_CHARGE_LIST, map);
		map=null;

		setAttribute("totalRows",new Integer(chargeItemList.size()<10?12:chargeItemList.size()));
		return "otherPayBillList";
	}

	/**
	    * 功能描述:处理费用记录  <br>
	    * @param payMethod - 支付方式
	    * @param chargeRecords - 费用记录
	    * @roseuid 4945E9B200AB
	    * @return Boolean
	    *
	    * Create author:xuhaidui <br>
	    * Create on:2008-12-24  <br>
	    * Edit author:  <br>
	    * Edit on:    <br>
	    * Why:     <br>
	    */
	public void handleChargeRecords(@Read(key="accountHouseId") Long houseId,
			@Read(key="businessCodeId") Long businessCodeId,
			@Read(key="chargeRecords")String chargeRecordStr){
		if(BlankUtil.isBlank(chargeRecordStr)){
			this.renderText("false");
			return ;
		}
		List<ChargeRecordVO> chargeRecords=new ArrayList<ChargeRecordVO>();
		Map map=(Map)this.getRequest().getSession().getAttribute(SELECT_OTHER_CHARGE_LIST);
		String []chargeRecordArray=chargeRecordStr.split(",");
		for(String chargeRecord:chargeRecordArray){
			chargeRecords.add((ChargeRecordVO)map.get(chargeRecord));
		}
		nonConventionalChargeService.handleChargeRecords(houseId, this.getUserId(), businessCodeId, chargeRecords);

		this.renderText("true");
	}

	/**
	    * 功能描述: 删除费用记录 <br>
	    * @param chargeRecordId - 费用记录Id
	    * @roseuid 4945FAE90399
	    * @return Boolean
	    *
	    * Create author:xuhaidui<br>
	    * Create on:2008-12-24  <br>
	    * Edit author:  <br>
	    * Edit on:    <br>
	    * Why:     <br>
	    */
	public void deleteChargeRecord(@Read(key="chargeRecordId")Long chargeRecordId){
		   nonConventionalChargeService.deleteChargeRecord(chargeRecordId);
		this.renderText("true");
	}

	/**
	    * 功能描述: 月末结算 <br>
	    * @param chargeRecordId -
	    * @roseuid 4945FAE90399
	    * @return Boolean
	    *
	    * Create author:xuhaidui<br>
	    * Create on:2008-12-24  <br>
	    * Edit author:  <br>
	    * Edit on:    <br>
	    * Why:     <br>
	    */
	 public void  monthBalance(@Read ChargeRecordVO chargeRecordVO,
			 @Read(key="accountHouseId")Long accountHouseId){
		 Map map=(Map)this.getRequest().getSession().getAttribute(SELECT_OTHER_CHARGE_LIST);

		 chargeRecordVO=(ChargeRecordVO)map.get(chargeRecordVO.getKeyword().toString());
		 chargeRecordVO.setAccountHouseId(accountHouseId);
		 nonConventionalChargeService.monthBalance(chargeRecordVO);
		 this.renderText("true");
	 }

	/***
	 * 功能描述:  跳转到调整页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initAdjustAdd(
			@Read(key="tractionId")@Out(key="transactionId") Long tractionId,
			@Read(key="statuz")@Out(key="statuz")String status,
			@Read(key="accountHouseId")@Out(key="accountHouseId") Long accountHouseId)
	{
		AdjustTransactionVO relie = transactionService.getAdjustTransByMasterId(tractionId);
		PeriodVO period = periodService.queryCurrentPeriod();
		relie.setPeriodId(period.getKeyword());
		relie.setPeriod(period.getPeriod());
		setAttribute("reliefTran", relie);
		return "initAdjustAdd";
	}

	/**
	 * 功能描述: 新增调整交易 <br>
	 * @param debit
	 * Create author:yandawei <br>
	 * Create on:2008-9-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addAdjust(@Read AdjustTransactionVO adjustTransVO,
			@Read(key="masterDebit") BigDecimal masterDebit)
	{
		DebitTransVO masterTrans = new DebitTransVO();
		masterTrans.setDebit(masterDebit);
		masterTrans.setTransactionId(adjustTransVO.getTransactionId());
		masterTrans.setSubAccountId(adjustTransVO.getSubAccountId());
		adjustTransVO.setPrincipalTrans(masterTrans);
		adjustTransVO.setCreator(getUserId());
		cashieringService.inputAdjustAccountForHand(adjustTransVO);
		this.renderText("true");
	}

	/***
	 * 功能描述:  跳转到减免页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initDerateAdd(
			@Read(key="tractionId")@Out(key="transactionId") Long tractionId,
			@Read(key="statuz")@Out(key="statuz")String status,
			@Read(key="accountHouseId")@Out(key="accountHouseId") Long accountHouseId)
	{
		AdjustTransactionVO relie = transactionService.getReliefTransByMasterId(tractionId);
		PeriodVO period = periodService.queryCurrentPeriod();
		relie.setPeriodId(period.getKeyword());
		relie.setPeriod(period.getPeriod());
		setAttribute("reliefTran", relie);
		return "initDerateAdd";
	}



	/***
	 * 功能描述:  新增减免交易<br>
	 * @param debit
	 * Create author:yandawei <br>
	 * Create on:2008-9-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addDerate(@Read AdjustTransactionVO reliefTransVO,
			@Read(key="masterDebit") BigDecimal masterDebit)
	{
		DebitTransVO masterTrans = new DebitTransVO();
		masterTrans.setDebit(masterDebit);
		masterTrans.setTransactionId(reliefTransVO.getTransactionId());
		masterTrans.setSubAccountId(reliefTransVO.getSubAccountId());
		reliefTransVO.setPrincipalTrans(masterTrans);
		reliefTransVO.setCreator(getUserId());
		cashieringService.inputReliefAccountForHand(reliefTransVO);
		this.renderText("true");
	}

	/***
	 * 功能描述:  挂起<br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String addSuspend(@Read(key="tractionId")Long tractionId,@Read(key="clazz")String clazz)
	{
		DebitTransVO debitVo = new DebitTransVO();
		debitVo.setTransactionId(tractionId);
		debitVo.setClazz(clazz);
		debitVo.setModifier(getUserId());
		transactionService.hangsTransaction(debitVo);
		setAttribute("parameter", 1);
		this.getRequest().setAttribute("refreshIframe", "connTabPanel");
		return "onlyRefresh";
	}

	/***
	 * 功能描述:  解除挂起<br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String unChainSuspend(@Read(key="tractionId")Long tractionId,@Read(key="clazz")String clazz)
	{
		DebitTransVO debitVo = new DebitTransVO();
		debitVo.setTransactionId(tractionId);
		debitVo.setClazz(clazz);
		debitVo.setModifier(getUserId());
		transactionService.liftingHangsTransaction(debitVo);
		setAttribute("parameter", 1);
		this.getRequest().setAttribute("refreshIframe", "connTabPanel");
		return "onlyRefresh";
	}


	/***
	 * 功能描述:  第一次加载从后台取数据<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-26  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String payBillDetailList(
			@Read(key="accountId")@Out(key="accountId")Long accountId,
			@Read(key="accountHouseId")Long accountHouseId
			)
	{
		ChargeDetailSearchVO searchVo = new ChargeDetailSearchVO();
		searchVo.setAccountId(accountId);
		searchVo.setOnlyDebit(true);
		SysrefcodeDO sysref =  sysrefcodeService.getSysrefCodesByCode(SysrefcodeDO.FEE_TRANSACTION_STATUZ, SysrefcodeDO.FEE_TRANSACTION_STATUZ_NOTPAY);
		searchVo.setStatuz(sysref.getValue());
		List<TransactionVO> temp = transactionService.getTransactionVoByConditions(searchVo);
		if(temp.size() == 1){
			this.getRequest().setAttribute("noRecord", "yes");
//			throw new BusinessException("charge:not_exists_paycharge",BusinessException.WARNING);
		}else {
			this.getRequest().setAttribute("noRecord", "no");
		}
		List list = initPayBillDetailList(temp.subList(0, temp.size()-1));
		getRequest().getSession().setAttribute(DEBIT_CACHE, list);
		getRequest().getSession().setAttribute(SELECT_TRANSACTION_LIST,getParentTransaction(list));
		setDebitTrans2Cache();
		setAttribute("payBillList", list);
		setAttribute("totalCurrency", getPayMoney());
		setAttribute("totalRows", new Integer(list.size()));
		return "payDetailList";
	}

	/***
	 * 功能描述:  获取缴费记录集中所有主交易<br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-10-22  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List<TransactionVO> getParentTransaction(List<TransactionVO> list){
		List<TransactionVO> parentTranList = new ArrayList<TransactionVO>();
		for(TransactionVO tran: list){
			if(tran.getParent() == null)
				parentTranList.add(tran);
		}
		return parentTranList;
	}

	private List<TransactionVO> getTransaction(List<TransactionVO> list){
		List<TransactionVO> parentTranList = new ArrayList<TransactionVO>();
		for(TransactionVO tran: list){
			if(tran.getCheckBox().isChecked())
				parentTranList.add(tran);
		}
		return parentTranList;
	}


	/***
	 * 功能描述:  界面展开,收缩节点操作显示(此处只管显示不管是否选中)<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String requestFromCache()
	{
		List list = (List) getRequest().getSession().getAttribute(DEBIT_CACHE);
		setAttribute("payBillList", list);
		setAttribute("totalRows", new Integer(list.size()));
		setAttribute("totalCurrency", getPayMoney());
		return "payDetailList";
	}

	/***
	 * 功能描述:  进行全选与全取消<br>
	 * @param id
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	public String cascadeChecked(@Read(key="transtionId")Long id,
			@Read(key="check")boolean checked)
	{
		getRootDebitTrans(id);
		//String str = getRequest().getQueryString();
		Map<Long,TransactionVO> map =  (Map<Long, TransactionVO>) getRequest().getSession().getAttribute(DEBIT_MAP);
		TransactionVO root = map.get(-1L);
		setSelectTransaction(root, checked);
		setSelectTreeNodeChecked(root.getTransactionId(),checked);
		refreshDebitTransCacheList();
		List list = (List) getRequest().getSession().getAttribute(DEBIT_CACHE);
		setAttribute("payBillList", list);
		setAttribute("totalCurrency", getPayMoney());
		setAttribute("totalRows", new Integer(list.size()));
		return "payDetailList";
	}


	/***
	 * 功能描述: 缴费 <br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */

	public void addPayBill(
			@Read CreditTransVO creditTransVO,
			@Read(key="payMode")String payModeStr,
			@Read(key="isVirtual")String isVirtual,
			@Read(key="accountHouseId")Long accountHouseId)
	{
		Set<DebitTransVO> debitSet = chargeTransactionList2DebitSet();
		if(debitSet.size()<1){
			clearCache();
			this.renderText("true");
			return ;
		}
		Set<CreditTransVO> creditSet = wrapPayMode(payModeStr);
		creditTransVO.setDebits(debitSet);

		creditTransVO.setCreator(getUserId());
		creditTransVO.setPrecinctCode(getPrecinctVOByHouseId(accountHouseId,isVirtual));
		//获取当前收费周期
		creditTransVO.setPeriodId(periodService.queryCurrentPeriod().getKeyword());
		creditTransVO.setAccountHouseId(accountHouseId);
		findPayBillMoney(creditSet, creditTransVO);
		cashieringService.payCostsForHand(creditTransVO);
		//执行完操作后清空缓存
		clearCache();
		this.renderText("true");
	}



	/***
	 * 功能描述: 清空缓存 <br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void clearCache()
	{
		getRequest().getSession().removeAttribute(SELECT_TRANSACTION_LIST);
		getRequest().getSession().removeAttribute(DEBIT_CACHE);
		getRequest().getSession().removeAttribute(DEBIT_MAP);
	}



	/***
	 * 功能描述:  联动选择收费项目与标准<br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void unitedSelect(){
		String selectId = this.getRequest().getParameter("selectId");
		String targetId = this.getRequest().getParameter("targetId");
		String houseId = this.getRequest().getParameter("houseId");
		if("chargeStdId".equals(targetId)){
			loadOptionXML(new Long(selectId),Long.parseLong(houseId));
		}else if("chargeItemId".equals(targetId)){
			loadOptionXML(null,Long.parseLong(houseId));
		}
	}


	/***
	 * 功能描述:  根据收费项目重新加载收费标准<br>
	 * @param chargeItemId
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void loadOptionXML(Long chargeItemId,Long houseId)
	{
		HttpServletResponse response = this.getResponse();
		response.setContentType("text/xml;charset=utf-8");
		response.setHeader("Cache-Control", "no-cache");
		String xmlStr = null;
		if(chargeItemId != null)
		    xmlStr = converToXML(chargeItemId,houseId);
		else
			xmlStr = converToXML(houseId);
		try {
			byte[] bytes = xmlStr.getBytes("utf-8");
			response.getOutputStream().write(bytes);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/***
	 * 功能描述:  根据收费标准查询其标准费用(只对其它类型标准有效)<br>
	 * @param chargeStandardId
	 * Create author:yandawei <br>
	 * Create on:2008-10-30  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void getChargeStandardPrice(@Read(key="chargeStandardId")Long chargeStandardId){
		ChargeStaVO standard = chargeStaService.findChargeStaById(chargeStandardId);
		Long chargeItemId = standard.getChargeItemId();
		ChargeItemVO item = chargeItemService.findChargeItemById(chargeItemId);
		if(SysrefcodeDO.FEE_CHAR_TYPE_CLASS_CODE_OTHER.equals(item.getChrgType())){
			ChargeStaVersionVO standardVersion = chargeStaService.findVersionByChargeStaId(chargeStandardId);
			this.renderText(standardVersion.getPrice().toString());
		}else{
			this.renderText("0");
		}

	}

	/***
	 * 功能描述: 将所选择收费项目下的标准格式化为xml文件 <br>
	 * @param chargeItemId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String converToXML(Long chargeItemId,Long houseId)
	{
		String xmlStr = null;
		List<ChargeStaVO> chargeStaList = getChargeStandardByChargeItem(chargeItemId,houseId);
		try {
			xmlStr = XMLAbout.convertListToSelectXML(chargeStaList, "staName", "keyword");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return xmlStr;
	}

	/***
	 * 功能描述:  根据房间ID找收费项目<br>
	 * @param houseId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-11-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String converToXML(Long houseId){
		String xmlStr = null;
		List<ChargeItemVO> list = getAllHouseSelectChargeItem(houseId);
		try {
			xmlStr = XMLAbout.convertListToSelectXML(list, "itemName", "keyword");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return xmlStr;
	}


	/***
	 * 功能描述: 将所有交易记录缓存的一个Map集合(主要是方便当选中一条交易记录时更改相应记录的checkbox checked 状态) <br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private void setDebitTrans2Cache()
	{
		List<TransactionVO> list = (List<TransactionVO>) getRequest().getSession().getAttribute(DEBIT_CACHE);
		Map<Long,TransactionVO> map = new HashMap<Long, TransactionVO>();
		for(TransactionVO debit  : list)
		{
			map.put(debit.getTransactionId(), debit);
		}
		getRequest().getSession().setAttribute(DEBIT_MAP, map);
	}


	/***
	 * 功能描述:  包装支付方式<br>
	 * @param payModeStr
	 * @param debitSet
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<CreditTransVO> wrapPayMode(String payModeStr)
	{
		Set<CreditTransVO> set = new HashSet<CreditTransVO>();
		Set<Long> valitionSet = new HashSet<Long>();
		String[] strs  = payModeStr.split(";");
		for(String str : strs)
		{
			String[] temps = str.split(",");
			CreditTransVO credit = new CreditTransVO();
			if(temps.length == 2)
			{
				credit.setCredit(new BigDecimal(temps[0]));
				credit.setBusinessId(Long.valueOf(temps[1]));

				boolean result = valitionSet.add(Long.valueOf(temps[1]));
				//若有重复交易方式则报错
				if(result == false)
				{
					throw new BusinessException("charge:charge_businesscode_duplicate_exception",BusinessException.WARNING);
				}
				set.add(credit);
				BusinessCodeVO code =  businessCodeService.findBusinessCodeByKeyword(Long.valueOf(temps[1]));
				SysrefcodeDO sysref =  sysrefcodeService.findSysrefcodeById(Long.valueOf(code.getPayMethod()));
				if(SysrefcodeDO.FEE_BUSINESS_CODE_PAY_METHOD_PENDING.equals(sysref.getValue()) && set.size()>1){
					throw new BusinessException("charge:charge_businesscode_only_suspend_exception",BusinessException.WARNING);
				}
			}
		}
		return set;
	}


	/***
	 * 功能描述:  设置选中的主交易到缓存<br>
	 * @param tran
	 * @param checked
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private void setSelectTransaction(TransactionVO tran , boolean checked)
	{
		List<TransactionVO> list = (List<TransactionVO>) getRequest().getSession().getAttribute(SELECT_TRANSACTION_LIST);
		if(checked)
		{
			if(list.contains(tran) == false)
				list.add(tran);
		}
		else
		{
			if(list.contains(tran))
				list.remove(tran);
		}
	}


	/***
	 * 功能描述: 设置选中节点的根点到缓存(key=-1) <br>
	 * @param id
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private void  getRootDebitTrans(Long id)
	{
		Map<Long,TransactionVO> map =  (Map<Long, TransactionVO>) getRequest().getSession().getAttribute(DEBIT_MAP);
		TransactionVO debit = map.get(id);
		map.put(-1L, debit);//根对应的VO
		if(debit.getParentId() != null)
			getRootDebitTrans(debit.getParentId());

	}

	/***
	 * 功能描述: 迭代操作子节点的选中状态 <br>
	 * @param rootId
	 * @param checked
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private void setSelectTreeNodeChecked(Long rootId,boolean checked)
	{
		Map<Long,TransactionVO> map =  (Map<Long, TransactionVO>) getRequest().getSession().getAttribute(DEBIT_MAP);
		TransactionVO root = map.get(rootId);
		if(root.getChildren() != null)
		{
			Set<TransactionVO> set = root.getChildren();
			for(TransactionVO debit: set)
			{
				debit.getCheckBox().setChecked(checked);
				debit.setCheckHead(buildCheckBox(debit.getCheckBox()));
				map.put(debit.getTransactionId(), debit);//将修改后的值重新放入缓存中
				setSelectTreeNodeChecked(debit.getTransactionId(),checked);
			}
		}
		root.getCheckBox().setChecked(checked);
		root.setCheckHead(buildCheckBox(root.getCheckBox()));
		map.put(root.getTransactionId(), root);
	}


	/***
	 * 功能描述:  更新交易列表缓存<br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private void refreshDebitTransCacheList()
	{

		Map<Long,TransactionVO> map =  (Map<Long, TransactionVO>) getRequest().getSession().getAttribute(DEBIT_MAP);
		List<TransactionVO> list = (List<TransactionVO>) getRequest().getSession().getAttribute(DEBIT_CACHE);
		map.remove(-1L);
		for(int index = 0 ; index< list.size() ;index++)
		{
			TransactionVO debit = map.get(list.get(index).getTransactionId());
			list.set(index, debit);
		}
		getRequest().getSession().setAttribute(DEBIT_CACHE, list);

	}

	/***
	 * 功能描述:  所选缴费项目总额<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private BigDecimal getPayMoney()
	{
		List<TransactionVO> list = (List<TransactionVO>) getRequest().getSession().getAttribute(DEBIT_CACHE);
		BigDecimal total = new BigDecimal("0.00",new MathContext(21,RoundingMode.HALF_UP));
		for(TransactionVO debit : list)
		{
			if(debit.getCheckBox().isChecked())
				total=total.add(debit.getPrice());
		}
		return total;
	}



	/***
	 * 功能描述:  主交易添加调,减,滞图片<br>
	 * @param sourceHead
	 * @param showType
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-17  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String addImageToHeadName(String sourceHead , String showType)
	{
		StringBuffer sb = new StringBuffer(sourceHead);
		if("adjust".equals(showType))
			sb.append("<img src=\"images/ico_tiaozheng.gif\" width=\"16\" height=\"16\">&nbsp");
		else if("derate".equals(showType))
			sb.append("<img src=\"images/ico_jianmian.gif\" width=\"16\" height=\"16\">&nbsp");
		else if("latefee".equals(showType))
			sb.append("<img src=\"images/ico_zhinajin.gif\" width=\"16\" height=\"16\">&nbsp");
		return sb.toString();
	}

	/***
	 * 功能描述:  获取所有收费周期<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-20  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List getAllPeriod()
	{
		return periodService.findPeriodByValidity(null);
	}

	/***
	 * 功能描述:  构建checkbox<br>
	 * @param id
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-20  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String buildCheckBox(CheckBox checkBox)
	{
		StringBuffer sb = new StringBuffer();
		sb.append("<input ")
		  .append(" name=").append("'checkbox").append(checkBox.getId()).append("'")
		  .append(" type=").append("'checkbox'")
		  .append(" value='").append(checkBox.getId()).append("'");
		if(checkBox.isChecked())
		{
			sb.append(" checked ");
		}
		sb.append(" onclick='cascadeCheck(").append("this").append(");'")
		.append(">");
		return sb.toString();
	}


	/***
	 * 功能描述:  获取所有收费项目(所有其它类型的收费项目和所有与该房间绑定的收费项目的集合)<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-20  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List getAllHouseSelectChargeItem(Long houseId)
	{
		List<ChargeStaChoVO> list = charStoChoGeneralService.getAllSelectHouseCharStoCho(houseId);
		List<ChargeItemVO> otherChargeItemList = chargeItemService.getAllChargeItemByType(SysrefcodeDO.FEE_CHAR_TYPE_CLASS_CODE_OTHER);
		List<ChargeItemVO> chargeItemList = new ArrayList<ChargeItemVO>();
		for(ChargeStaChoVO chargeStachoVO : list){
			ChargeItemVO chargeItem = new ChargeItemVO();
			chargeItem.setKeyword(chargeStachoVO.getChargeItemID());
			chargeItem.setItemName(chargeStachoVO.getChargeItemName());
			chargeItemList.add(chargeItem);
		}
		chargeItemList.addAll(otherChargeItemList);
		return chargeItemList;
	}

	/***
	 * 功能描述:  根据收费项目ID找出所属的收费标准<br>
	 * @param chargeItemId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-20  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List<ChargeStaVO> getChargeStandardByChargeItem(Long chargeItemId,Long houseId)
	{
		List<ChargeStaChoVO> list = charStoChoGeneralService.getAllSelectHouseCharStoCho(houseId);
		List<ChargeStaVO> chargeStaList = new ArrayList<ChargeStaVO>();
		for(ChargeStaChoVO chargeStachoVO : list){
			if(chargeItemId.equals(chargeStachoVO.getChargeItemID())){
				ChargeStaVO chargeSta = new ChargeStaVO();
				chargeSta.setKeyword(chargeStachoVO.getChargeStaID());
				chargeSta.setStaName(chargeStachoVO.getChargeStaName());
				chargeStaList.add(chargeSta);
				break;
			}
		}
		if(BlankUtil.isBlank(chargeStaList)){
			chargeStaList = chargeStaService.queryAllChargeSatBy(chargeItemId);
		}
		return chargeStaList;
	}

	/***
	 * 功能描述:  计算支付总金额<br>
	 * @param creditSet
	 * @param creditTransVO
	 * Create author:yandawei <br>
	 * Create on:2008-11-3  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void findPayBillMoney(Set<CreditTransVO> creditSet,CreditTransVO creditTransVO)
	{
		BigDecimal total = BigDecimalUtil.getZEROInstance();
		for(Iterator<CreditTransVO> it = creditSet.iterator(); it.hasNext();){
			CreditTransVO temp = it.next();
			creditTransVO.setBusinessId(temp.getBusinessId());
			total = total.add(temp.getCredit());
		}
		if(creditSet.size() > 1){//若有多重支付方式,则设为多重支付交易码
			ParameterDefVO parameter =  parameterDefService.findParameterDefByPkey(SysrefcodeDO.MULTIPLE_PAY_CODE);
			creditTransVO.setBusinessId(parameter.getPvalue());
			creditTransVO.setChildrens(creditSet);
		}
		creditTransVO.setCredit(total);
	}

	/***
	 * 功能描述:  将用于前台显示的交易VO(TransactionVO)转为实收VO(DebitTransVO)<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@SuppressWarnings("unchecked")
	private Set<DebitTransVO> chargeTransactionList2DebitSet()
	{
		List<TransactionVO> list = (List<TransactionVO>) getRequest().getSession().getAttribute(SELECT_TRANSACTION_LIST);
		Set<DebitTransVO> set = new HashSet<DebitTransVO>();
		for(TransactionVO tran : list)
		{
			DebitTransVO debit = new DebitTransVO();
			debit.setTransactionId(tran.getTransactionId());
			debit.setDebit(tran.getPrice());
			//debit.setReceivablePrice(getPayMoney());
			set.add(debit);
		}
		return set;
	}


	/***
	 * 功能描述:  为支付明细构建checkbox<br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List<TransactionVO> initPayBillDetailList(List<TransactionVO> list)
	{
		for(TransactionVO tran : list)
		{
			CheckBox box = new CheckBox(tran.getTransactionId(),true);
			tran.setCheckBox(box);
			tran.setCheckHead(buildCheckBox(box));
		}
		return list;
	}

	/***
	 * 功能描述: 费用明细滞,减,调图片显示 <br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List<TransactionVO> initChargeDetailList(List<TransactionVO> list)
	{
		for(TransactionVO tran : list)
		{
			tran.setTransNameWithImage(tran.getTransName());
			if(tran.getParent()  == null && tran.getChildren() != null)
			{
				String temp = tran.getTransNameWithImage();
				Set<TransactionVO> children = tran.getChildren();
				boolean hasAdjust = false;
				boolean hasLateFee = false;
				boolean hasDerate = false;
				for(TransactionVO t : children)
				{
					if(hasAdjust && hasLateFee && hasDerate)
					{
						break;
					}
					if(SysrefcodeDO.FEE_TRANSACTION_CLAZZ_ADJUSTMENT.equals(t.getClazz()) && hasAdjust == false)
					{
						temp = addImageToHeadName(temp, "adjust");
						hasAdjust = true;
					}
					if(SysrefcodeDO.FEE_TRANSACTION_CLAZZ_LATEFEES.equals(t.getClazz()) && hasLateFee == false)
					{
						temp = addImageToHeadName(temp, "latefee");
						hasLateFee = true;
					}
					if(SysrefcodeDO.FEE_TRANSACTION_CLAZZ_RELIEF.equals(t.getClazz()) && hasDerate == false)
					{
						temp = addImageToHeadName(temp, "derate");
						hasDerate = true;
					}
					tran.setTransNameWithImage(temp);
				}
			}
		}
		return list;
	}

	/**
	 * 功能描述:获得管理区的编号
	 * @param keyword 房间的id
	 * @param isVirtual 是否是管理区 1是; 0不是
	 * @return
	 *
	 * Create author:xuhaidui
	 * Create on:2008-9-17
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    private String getPrecinctVOByHouseId(Long keyword, String isVirtual){
    	return houseService.getPrecinctVOByHouseId(keyword,isVirtual).getPrecinctCode();
    }

	public void setMeterDataRegisterService(
			IMeterDataRegisterService meterDataRegisterService) {
		this.meterDataRegisterService = meterDataRegisterService;
	}

	public void setCashieringService(ICashieringService cashieringService) {
		this.cashieringService = cashieringService;
	}

	public void setChargeStaService(IChargeStaService chargeStaService) {
		this.chargeStaService = chargeStaService;
	}

	public void setChargeItemService(IChargeItemService chargeItemService) {
		this.chargeItemService = chargeItemService;
	}


	public void setMeterService(IMeterService meterService) {
		this.meterService = meterService;
	}


	public void setCoalitionHouseService(
			ICoalitionHouseService coalitionHouseService) {
		this.coalitionHouseService = coalitionHouseService;
	}

	public void setPeriodService(IPeriodService periodService) {
		this.periodService = periodService;
	}

	public void setTransactionService(ITransactionService transactionService) {
		this.transactionService = transactionService;
	}

	public void setBankAccountService(IBankAccountService bankAccountService) {
		this.bankAccountService = bankAccountService;
	}

	public void setFeeBankService(IFeeBankService feeBankService) {
		this.feeBankService = feeBankService;
	}

	public void setBusinessCodeService(IBusinessCodeService businessCodeService) {
		this.businessCodeService = businessCodeService;
	}

	public void setPrePaySchService(IPrePaySchService prePaySchService) {
		this.prePaySchService = prePaySchService;
	}

	public void setSubAccountService(ISubAccountService subAccountService) {
		this.subAccountService = subAccountService;
	}

	public void setParameterDefService(IParameterDefService parameterDefService) {
		this.parameterDefService = parameterDefService;
	}

	public void setHouseService(IHouseService houseService) {
		this.houseService = houseService;
	}

	public void setAccountService(IAccountService accountService) {
		this.accountService = accountService;
	}

	public void setNoteService(INoteService noteService) {
		this.noteService = noteService;
	}

	public ICharStoChoGeneralService getCharStoChoGeneralService() {
		return charStoChoGeneralService;
	}

	public void setCharStoChoGeneralService(
			ICharStoChoGeneralService charStoChoGeneralService) {
		this.charStoChoGeneralService = charStoChoGeneralService;
	}

	public void setCollectionService(IBankCollectionService collectionService) {
		this.collectionService = collectionService;
	}

	public void setNonConventionalChargeService(
			INonConventionalChargeService nonConventionalChargeService) {
		this.nonConventionalChargeService = nonConventionalChargeService;
	}

	private IChargeItemService chargeItemService;

	private IChargeStaService chargeStaService;

	private ICashieringService cashieringService;

	private IMeterService meterService;

	private IMeterDataRegisterService meterDataRegisterService;

	private INoteService noteService;

	private IPeriodService periodService;

	private IPrePaySchService prePaySchService;

	private IBusinessCodeService businessCodeService;

	private ITransactionService transactionService;

	private ICoalitionHouseService coalitionHouseService;

	private IBankAccountService bankAccountService;

	private IFeeBankService feeBankService;

	private ISubAccountService subAccountService;

	private IAccountService accountService;

	private IParameterDefService parameterDefService;

	private IHouseService houseService;

	private ICharStoChoGeneralService charStoChoGeneralService;

	private INonConventionalChargeService nonConventionalChargeService;

	private IBankCollectionService collectionService;

	private final String DEBIT_CACHE = "debit_cache";

	private final String DEBIT_MAP = "debit_map";

	private final String SELECT_TRANSACTION_LIST = "select_transaction_list";

	private final String SELECT_OTHER_CHARGE_LIST = "SELECT_OTHER_CHARGE_LIST";





}
